<template>
	<nav-header title="企业税务">
		<view class="grid grid-cols-2 gap-4 m-4 pt-4 mb-8">
			<view v-for="(config,key) in topFunc" :key="key" class="bg-white flex items-center justify-center rounded-lg py-4" @tap="$util.myNavigateTo(config.navUrl)">
				<image :src="config.pic" style="width: 3.5rem;height: 3.5rem;"></image>
				<text class="text-black-33 font-bold pl-3" v-text="config.name"></text>
			</view>
		</view>
		<view class="mx-4">
			<view class="px-2 mb-4 text-base font-bold text-color-theme">相关公司</view>
			<view class="bg-white px-2 rounded-lg">
				<my-page ref="mypage" v-model="dataList" :height="system.screenHeight - system.statusBarHeight - 217" :contentClass="['py-2']" @load-data="loadData">
					<template slot="content">
						<view v-for="(item,index) in dataList" :key="index" class="px-1 py-4 flex justify-between items-center" 
							:class="{'border-b-ee': index != (dataList.length - 1)}" @click="$util.myNavigateTo('/pages_home/lianmeng/company_detail?id=' + item.id)">
							<u-image :showLoading="true" :src="$util.formatImageIdUrl(item.logo)" radius="4" width="100" height="80"></u-image>
							<view class="pl-3 flex justify-between items-center" style="width: calc(100% - 100px);">
								<view>
									<view class="text-black-32 font-bold zx-ellipsis" v-text="item.name"></view>
									<view class="mt-4 zx-multi-ellipsis--2" v-text="$util.html2Text(item.content)"></view>
								</view>
								<u-icon name="arrow-right" color="#bfbfbf" size="20"></u-icon>
							</view>
						</view>
					</template>
				</my-page>
			</view>
		</view>
		<view v-if="formCode" class="fixed bottom-10 right-5 flex flex-col items-center justify-center w-12 h-12 rounded-full bg-theme text-xs text-white" @click="$util.myNavigateTo('/pages_form/detail/index?formCode='+formCode)">
			<text>税务</text>
			<text>咨询</text>
		</view>
	</nav-header>
</template>

<script>
	import {mapState} from 'vuex'
	import NavHeader from '@/components/nav_header.vue'
	import MyPage from '@/components/my_page.vue'
	import * as unionApi from '@/interface/junchuang/union.js'
	import MescrollPageMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-page.js"
	export default {
		mixins: [MescrollPageMixin],
		components: {
			NavHeader,MyPage
		},
		data() {
			return {
				formCode: '',
				dataList: [],
				data: {pageTotal: 0},
				topFunc: {
					fnc1: {name: '前景分析', pic: './static/qianjingfenxi.png', navUrl: '/pages/common/article_list?code=prospective_analysis'},
					fnc2: {name: '团队服务', pic: './static/tuanduifuwu.png', navUrl: '/pages/common/article_list?code=team_service'},
				}
			}
		},
		computed: {
			...mapState({
				user: state => state.user,
				system: state => state.system
			})
		},
		onReady() {
			const v = this
			if (v.user.token) v.formCode = v.$util.getFormCode('企业税务')
		},
		methods: {
			loadData(page, success, error){
				const v = this;
				Object.assign(v.data, page, {
					type: '5'
				})
				unionApi.getCompanyPageList(v.data).then(res=>{
					v.data.pageTotal = res.data.total || 0
					success(res)
				}).catch(error)
			},
		}
	}
</script>

<style>
	page{
		background-color: #f7f7f7;
	}
	
</style>
